<%@ page contentType="text/html; charset=utf-8" import="java.net.InetAddress,common.*,java.sql.*,db.*,java.util.*"%>
<%@ taglib uri="/WEB-INF/commontags.tld" prefix="common" %><%--페이징처리tag--%>
<jsp:include page="/mobile/common/head.jsp"></jsp:include>

<%
UserSession userSession = (UserSession)session.getAttribute("user");
String login_id  = "";
if(userSession != null){
	login_id  = userSession.getLogin_id();
}

String ent_id= CommonUtil.nvl((String)session.getAttribute("ent_id"));
String ent_nm = (String)request.getParameter("ent_nm")==null?(String)session.getAttribute("ent_nm"):(String)request.getParameter("ent_nm");

String menu_type 		= CommonUtil.nvl((String)session.getAttribute("menu_type")); 

String total_count= request.getParameter("total_count");
if( total_count == null || total_count.equals("")) total_count = "0";
String curr_page = request.getParameter("curr_page");
if( curr_page == null || curr_page.equals("")) curr_page = "1";
String one_page = request.getParameter("one_page");
if( one_page == null || one_page.equals("")) one_page = "5";
String one_group = request.getParameter("one_group");
if( one_group == null || one_group.equals("")) one_group = "10";


Connection con=null;
ArrayList list =null;
HashMap map  = null;
try {
	
	con = (new CommonConnect()).getConnection_ds1();
	
	String[] param=null;
	
	// 메인페이지의 리스트 내역을 가져온다.
	param= new String[6];
	param[0] = "";
	param[1] = "1";
	param[2] = ent_id;
	param[3] = one_page;
	param[4] = total_count;
	param[5] = curr_page;
				 
	String queryStr ="";

	
	queryStr = "call stu_edu1601List2(?, ?, ?, ?, ?, ?)";	
	list = DAO.select(con,queryStr,param);
		
	System.out.println(list);
	
} catch (Exception e) {
	e.printStackTrace();
}finally {
	  try{
		  if (con!=null) con.close();
	  }catch(Exception ee){}
}

if (list!=null && list.size()>0) {
	map=(HashMap)list.get(0);
	total_count = (String)map.get("total_row");
	System.out.println("토탈카운트"+total_count);
}

String attach_id     = "";
String attach_id_old     = "";

if(total_count == null) total_count= "0";


%>

<script>  
        $(function()  
        {  
          
            $("#btn_ChangePage").bind("click",function()  
                {  
                    /* 
                     동적으로 페이지를 이동시키고 싶은경우는? chnagePage()를 사용하면 된답니다. 
                        changePage - 파라메터 
                            - to : 이동페이지 
                            - transition : 이동효과 
                            - reverse : reverse여부  
                            - changeHash : hash 데이터 업데이트 여부. 
                    */  
                    $.mobile.changePage("#subpage","slide", false, true);  
                  
                }  
            );  
        });  
</script>

<script >

// 페이지 번호를 눌렸을때.
	function go_page(page){
		var frm = document.mainform;
		<%-- 검색 조건은 hidden에 들어있음 --%>
		frm.curr_page.value = page ;			<%-- 조회할 페이지 번호 --%>
		frm.total_count.value = "<%=total_count%>";
		frm.action = '/mobile/notice.jsp';
		frm.target="_self";
		frm.submit();
	}
	
	function go_detail(id){
		frm = document.mainform;
		frm.action = '/mobile/notice_view.jsp';
		frm.blt_cont_no.value=id;
		frm.target= '_self';
		frm.curr_page.value = "<%=curr_page%>" ;			<%-- 조회할 페이지 번호 --%>
		frm.total_count.value = "<%=total_count%>";              
		frm.submit();   
	
}

</script>
<body>
<div data-role="page">
	<div data-role="header">
    	<h1>공지사항</h1>
    </div>
    <div data-role="content">
<form name="mainform"  method="post">
<input type="hidden" name="blt_cont_no" value="">
<input type="hidden" name="curr_page" value="<%=curr_page%>">
<input type="hidden" name="one_page"  value="<%=one_page%>">
<input type="hidden" name="one_group" value="<%=one_group%>">
<input type="hidden" name="total_count" value="<%=total_count%>">
</form>	    
    	
    	
    	<ul data-role="listview" data-theme="d" data-inset="true">
            
            <%

			for (int i=0; list!=null && list.size() > i; i++){
				map=(HashMap)list.get(i);
										
			%>  
			<%if(map.get("fix_yn").equals("Y")){ %>  
			<li>
				<h3><a href="javascript:go_detail('<%=map.get("blt_cont_no")%>');">[공지]<%=map.get("title")%></a></h3>   
                <p><%=map.get("reg_dt")%></p>
				<span class="ui-li-count"><%=map.get("read_cnt")%></span>			
			</li>					
			<%}else{
				int cnt=0;
				cnt++;
			%>  
			<li>
				<h3><a href="javascript:go_detail('<%=map.get("blt_cont_no")%>');"><%=map.get("title")%></a></h3>   
                <p><%=map.get("reg_dt")%></p>
				<span class="ui-li-count"><%=map.get("read_cnt")%></span>			
			</li>		 
			<%} 
			} 
			if(list ==null ||  0>=list.size()){
			%>              
            <li>공지사항 목록이 없습니다.</li>
            <%} %>
        </ul>
       
    
    
    </div>

 	<!-- 
 	<div data-role="footer"  data-theme="d" style="text-align:center;height:40px;padding-top:7px">
              
              <a href="#" >이전</a>     
              <a href="#" > 1 / 5 </a>    
              <a href="#" >다음</a> 
               
    </div>
    -->
 	<common:pagelistmobile currPage="<%=curr_page%>" total="<%=total_count%>" onePage="<%=one_page%>" oneGroup="<%=one_group%>"/>
      
    <jsp:include page="/mobile/common/footer.jsp"></jsp:include>
    
</div>
</body>
</html>
